//
// Created by francklinson on 2022/1/1 AT 14:50.
//
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

class Solution {
public:
    vector<int> findEvenNumbers(vector<int> &digits) {
        // 结果是100-999
        // 判断能不能用给出的数组来组成
        unordered_map<int, int> counter;
        for (const int &x:digits)
            ++counter[x];
        vector<int> ans;
        for (int i = 100; i < 999; ++i) {
            if (i % 2 == 0) {
                // 这个偶数的各位
                unordered_map<int, int> freq;
                bool available = true;
                int temp = i;
                while (temp) {
                    ++freq[temp % 10];
                    temp = temp / 10;
                }
                if (all_of(freq.begin(), freq.end(), [&](const auto& x){
                    return counter[x.first] >= freq[x.first];
                })){
                    ans.push_back(i);
                }
            }
        }
        return ans;
    }
};

int main() {
    vector<int> digits{2, 1, 3, 0};
    Solution solution;
    vector<int> ans = solution.findEvenNumbers(digits);
    for (const int &x:ans) cout << x << endl;
    return 0;
}

